<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="app">
    <ul v-for="(fruit,index) in fruits">
        <li >{{fruit.name}}:{{fruit.price}}
            <button @click="removeItem(index)">X</button>
        </li>
    </ul>
</div>
</body>
</html>
<script>
    new Vue({
        el: '#app',
        data: {
            fruits:[
                {name:'苹果',price:10},
                {name:'西瓜',price:5},
                {name:'榴莲',price:30},
                {name:'橘子',price:10},
                {name:'葡萄',price:13},
            ]
        },
        methods:{
            removeItem(index){
                this.fruits.splice(index,1);
            }
        }
    })
</script>
